<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<script>
    // 创建数组
    var  arr = [1,2,3,4,2,5,6,2,7,2];
    // index表示新数组newarr的下标，默认为0
    var  index = 0,newarr = [];
    // 遍历数组
    for(var i in arr){
        // 数组元素不全等于2,则将其保存到newarr中
        if(arr[i] !== 2){
            newarr[index] = arr[i];
            ++index;
        }
    }

</script>
</body>
</html>